﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace V2
{

    public class ChangeHooks
    {
        public ChangeHooks( IStreamingSet set )
        {
            set.RowBinding += Route;
        }

        private void Route( IStreamingSet sender, ChangeArgs args ) {
            switch( args.ChangeType ) {
                case ChangeType.Add: if (AdditionPending != null) AdditionPending( sender, args );
                    break;
                case ChangeType.Remove: if (RemovalPending != null) RemovalPending(sender, args);
                    break;
                case ChangeType.Update: if (UpdatePending != null) UpdatePending(sender, args);
                    break;
                case ChangeType.Clear: if (ClearPending != null) ClearPending(sender, args);
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }

        public event ChangeHandler AdditionPending;
        public event ChangeHandler UpdatePending;
        public event ChangeHandler RemovalPending;
        public event ChangeHandler ClearPending;

    }
}
